a = [1, 2, 3, 7], b = [2, 5, 7]

function solution(a, b) {
    let Hash = {}
    let result = []
    a.forEach((item) => {
        if (!Hash[item]) {
            Hash[item] = true
        }
    })
    b.forEach((item) => {
        if (Hash[item]) {
            result.push(item)
            delete Hash[item]
        }
    })
    return result.sort((a, b) => b - a)
}
console.log(solution(a, b));
